#ifndef OBJECTFACTORY_H
#define OBJECTFACTORY_H

#include "purgatory.h"
#include "package.h"
#include "bullet.h"

class ObjectFactory
{
private:

    Purgatory* purgatory;

public:

    ObjectFactory(Purgatory* p)
    {
        purgatory=p;
    }

    Package* createPackage(pt::PackageType ptype,int value)
    {
        Package* p=dynamic_cast<Package*>(purgatory->package());
        if(p==NULL)p=new Package(ptype,value);
        else
        {
            p->set(ptype,value);
            p->show();
            p->alive=true;
        }
        return p;
    }

    Bullet* createBullet(Object* o)
    {
        Bullet* p=static_cast<Bullet*>(purgatory->bullet());
        if(p==NULL)p=new Bullet(o);
        else
        {
            p->parent=o;
            p->tile=o->tile;
            p->alive=true;
            p->speed=20.0f;
            p->show();
            p->resetTransform();
        }
        return p;
    }

};

#endif // OBJECTFACTORY_H
